<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数</title>
</head>
<body>
<button onclick="alert('警告')">警告框</button>
<button onclick="confirm('确认')">确认框</button>
<button onclick="prompt('提示')">输入框</button>
<script>
    console.log(parseInt(6.6));//6
    console.log(parseInt(6.1));//6
    console.log(parseFloat('fjf'));//NaN
    console.log(parseInt('23dg35'))//23

    console.log(parseFloat(5.5));//5.5
    console.log(parseFloat(5));//5
    console.log(parseFloat('fdgd'));//NaN
    console.log(parseFloat('5.5dg4.3'));//5.5

    console.log(isNaN('fjf'));//true
    console.log(isNaN(5));//false



    // 1.函数声明:JS通过关键字function定义函数
    function f1(){
        console.log('f1')
    }
    f1();
    f1();
    f1();
    // 2.带参数的函数，函数调用:函数名+括号
    function f2(n){
        console.log(n)
    }
    f2(1);
    f2(false);
    f2(null);
    //
    function f3(n,m){
        console.log(n+m)
    }
    f3(1,2);//3
    f3(1);//1 + undefined = NaN
    f3(1,2,3);//3
    //arguments:函数调用时，传递的参数集合
    function f4(){
        console.log(arguments);//
    }
    f4(1,2,3);
    // 3.返回值:return
    function f5(a,b){
        return a + b;
    }
    var result =f5(1,2);
    console.log(result);//保存在result变量中再打印
    console.log(f5(1,2));//直接打印

    //第二种函数声明方式
    var f6 = function (){
        console.log('f6')
    }
    f6();
    console.log(f6,typeof f6);

    //第三种声明方式
    const f7 = (n)=>{
        console.log('箭头函数' + n);
    }
    f7(1);
    f7('你好');
</script>

</body>
</html>